<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<%@ include file="/WEB-INF/jsp/inc/taglibs.jsp"%>
	<%@ include file="/WEB-INF/jsp/inc/meta.jsp"%>
<script type="text/javascript" src="${approot}/resource/jquery/validate/jquery.validate.js"></script>
   <link href="${approot}/resource/jquery/validate/jquery.validate.css" rel="stylesheet" type="text/css" />
   <link href="${approot}/resource/jquery/validate/style.css" rel="stylesheet" type="text/css" />
   
     <script type="text/javascript">
            /* <![CDATA[ */
            jQuery(function(){
            	//parent.frames['tree'].location.reload();
                jQuery("#name").validate({
                    expression: "if (VAL) return true; else return false;",
                    message: "部门名称不能为空"
                });   
                jQuery('#dept').validated(function(){
					//alert("通过验证");
					do_add();
				});
            });
            /* ]]> */
        </script>
        
        <script type="text/javascript">
        function do_add()
        {   
            var str=$('#dept').serializeObject();
            var jsons = $.toJSON(str);
            add_dept(jsons);
        }


        function add_dept(jsons){
 	       $.ajax({
 		   	url:'${approot}/admin/dept/add',
 		   	dataType: 'json',
 		   	contentType: 'application/json',
 			data:jsons,
 			type:'post',
 			beforeSend:function(){
 			  // $('#main').disabled='true';
 			},
 			error:function(request){
 				//alert(S);
 			},
 			success:function(data){
 			   if(data.msg=="error")
 			   {
 	 			   alert('部门名称已经存在,请重新输入');
 			   }
 			   if(data.msg=="succ")
 			   {
 				  alert('部门添加成功');
 			   }
 			}
 		   });
 	}
        </script>
   
</head>  
  <body style="background:#E8F5FE; padding:15px 18px;" class="scroll_r">
<div id="right_w"><p>当前位置：系统管理 >>用户修改</p></div>
<table border="0" cellpadding="" cellspacing="1" align="center" width="92%" id="web_tab">
<caption style="text-align: right;margin-bottom:4px;">
<button class="but" onclick="location.href='${approot}/admin/user/to_add'">添加用户</button>
</caption>
 <tr>
  <th><input type="checkbox" name="all" value="all" onclick="checkAll(this.checked)"/> </th>
  <th>用户名</th>
  <th>真实姓名</th>
  <th>所属部门</th>
  <th>所属角色</th>
  <th>操作</th>
 </tr>
<c:forEach var="item" items="${items}">
 <tr>
  <td><input type="checkbox" name="ids" value="${item.id}"/></td>
  <td>${item.name}</td>
  <td>${item.realname}</td>
  <td>
  ${item.dept.name}
</td>

   <td>
 <c:if test="${item.roleIDS=='0'}"><font color='red'>未设置</font></c:if>
 <c:if test="${item.roleIDS!='0'}">${item.roleNames}</c:if>
 </td>

  <td>
  <a href="${approot}/admin/user/delete/${item.id}" onclick="return confirm('删除后不可恢复,确认删除?')">删除</a>
  <a href="${approot}/admin/user/to_edit/${item.id}">修改</a>
  
    <c:if test="${item.roleIDS=='0'}">
  <a href="${approot}/admin/user/to_add_role/${item.id}">分配角色</a>
  </c:if>
  <c:if test="${item.roleIDS!='0'}">
  <a href="${approot}/admin/user/to_edit_role/${item.id}">修改角色</a>
  </c:if>
  
   </td>
 </tr>
 </c:forEach>
</table>
</body>
</html>
